package com.dingli.shop.impl;

import com.dingli.shop.po.Report.Legend;
import com.dingli.shop.po.Report.Series;
import com.dingli.shop.po.Report.XAxis;
import com.dingli.shop.po.Report.YAxis;
import com.dingli.shop.po.ReportVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.List;


@Service
public class ReportBizImpl implements ReportBiz {

    @Autowired
    private SeriesBiz seriesBiz;

    @Override
    public ReportVO findReport() {
        try {

           List<Object> legendData = seriesBiz.findLegendData();
           List<Series> listSeries = seriesBiz.findSeries();

            ReportVO reportVO = new ReportVO();
            Legend legend = new Legend();
            legend.setData(legendData);

            List<XAxis> list1 = new ArrayList<XAxis>();
            XAxis xAxis = new XAxis();
            List data1 = new ArrayList();
            data1.add("2017-12-27");
            data1.add("2017-12-28");
            data1.add("2017-12-29");
            data1.add("2017-12-30");
            data1.add("2017-12-31");
            data1.add("2018-1-1");
            xAxis.setData(data1);
            list1.add(xAxis);

            List<YAxis> list2 = new ArrayList<YAxis>();
            YAxis yAxis = new YAxis();
            list2.add(yAxis);

            reportVO.setxAxis(list1);
            reportVO.setyAxis(list2);
            reportVO.setSeries(listSeries);
            reportVO.setLegend(legend);
            return reportVO;
        } catch (Exception e) {
            return null;
        }
    }
}
